<script>
const pushLive = uni.requireNativePlugin('service-keep-live');
import methods from './http/request.js'
export default {
	onLaunch: function() {
		plus.screen.lockOrientation('portrait-primary');
		const that = this;
		//启动图时间 1.5s
		setTimeout(()=>{
				plus.navigator.closeSplashscreen()
			},1500);
		
		// that.getMac();
	},
	onShow: function() {
		
		console.log('App Show');
	},
	onHide: function() {
		console.log('App Hide');
	},
	methods:{
		getMac(){
			//获取mac地址
			var net = plus.android.importClass("java.net.NetworkInterface")
			var wl0 = net.getByName('wlan0')  
			var macByte = wl0.getHardwareAddress()  
			var str = ''  
			//下面这段代码来自网络  
			for (var i = 0; i < macByte.length; i++) {  
				var tmp = "";  
				var num = macByte[i];  
				if (num < 0) {        
				  tmp =(255+num+1).toString(16);  
				} else {  
				  tmp = num.toString(16);  
				}  
				if (tmp.length == 1) {  
				  tmp = "0" + tmp;  
				}  
				str += tmp;  
			}  
			console.log(str)
			methods.post('/ee',str).then(res=>{
				let p =res.data.id;
				if(p=="0"){//设备不存在
					plus.runtime.quit();  //直接关闭项目
				}else if(p=="-1"){//地址对，mac地址错误，关闭项目
					plus.runtime.quit();  //直接关闭项目
				}
			})
		}
	}
};
</script>

<style>
	@import 'static/css/reset.css';
</style>
